home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kcmultidialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-22  |  9.1 KB  |  285 lines

  1. /*
  2.    Copyright (c) 2000 Matthias Elter <elter@kde.org>
  3.    Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
  4.    Copyright (c) 2003 Matthias Kretz <kretz@kde.org>
  5.  
  6.    This library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Library General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2 of the License, or (at your option) any later version.
  10.  
  11.    This library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Library General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU Library General Public License
  17.    along with this library; see the file COPYING.LIB.  If not, write to
  18.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.    Boston, MA 02110-1301, USA.
  20.  
  21. */
  22.  
  23. #ifndef KCMULTIDIALOG_H
  24. #define KCMULTIDIALOG_H
  25.  
  26. #include <qptrdict.h>
  27.  
  28. #include <kdialogbase.h>
  29. #include <klocale.h>
  30. #include <kservice.h>
  31.  
  32. class KCModuleProxy;
  33. class KCModuleInfo;
  34.  
  35. /**
  36.  * @ingroup kcmodule
  37.  * @short A method that offers a KDialogBase containing arbitrary
  38.  *        KControl Modules.
  39.  *
  40.  * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
  41.  * @since 3.2
  42.  */
  43. class KUTILS_EXPORT KCMultiDialog : public KDialogBase
  44. {
  45.     Q_OBJECT
  46.  
  47. public:
  48.     /**
  49.      * Constructs a new KCMultiDialog
  50.      *
  51.      * @param parent The parent widget
  52.      * @param name The widget name
  53.      * @param modal If you pass true here, the dialog will be modal
  54.      **/
  55.     KCMultiDialog( QWidget *parent=0, const char *name=0, bool modal=false );
  56.  
  57.     /**
  58.      * Construct a personalized KCMultiDialog.
  59.      *
  60.      * @param dialogFace You can use TreeList, Tabbed, Plain, Swallow or
  61.      *        IconList.
  62.      * @param caption The dialog caption. Do not specify the application name
  63.      *        here. The class will take care of that.
  64.      * @param parent Parent of the dialog.
  65.      * @param name Dialog name (for internal use only).
  66.      * @param modal Controls dialog modality. If @p false, the rest of the
  67.      *        program interface (example: other dialogs) is accessible while
  68.      *        the dialog is open.
  69.      */
  70.     KCMultiDialog( int dialogFace, const QString & caption, QWidget * parent = 0, 
  71.             const char * name = 0, bool modal = false );
  72.  
  73.  
  74.    /**
  75.      * Constructor for the predefined layout mode where you specify the
  76.      * kind of layout (face) and also add buttons. Note that the User1 button
  77.      * of KDialogBase is already used to provide a "Reset" button so only
  78.      * two more buttons are available to users of KCMultiDialog. When clicked 
  79.      * they trigger slotUser2() and slotUser3(). 
  80.      *
  81.      * @note If any root modules are added to the dialog when this constructor is 
  82.      * used, it will not be able to run them with root privileges. Since that will 
  83.      * render them useless, it is a good idea to use another constructor. In KDE 4 
  84.      * the argument @p user3 will be removed.
  85.      *
  86.      * @param dialogFace You can use TreeList, Tabbed, Plain, Swallow or
  87.      *        IconList.
  88.      * @param user2 User button2 text item.
  89.      * @param user3 User button3 text item.
  90.      * @param buttonMask Specifies which buttons will be visible. If zero
  91.      *        (0) no extra buttons will be added. You can only use the User2 and
  92.      *        User3 buttons. The User1 button is already used internally.  See
  93.      *        KDialogBase for more information on this.
  94.      * @param caption The dialog caption. Do not specify the application name
  95.      *        here. The class will take care of that.
  96.      * @param parent Parent of the dialog.
  97.      * @param name Dialog name (for internal use only).
  98.      * @param modal Controls dialog modality. If @p false, the rest of the
  99.      *        program interface (example: other dialogs) is accessible while
  100.      *        the dialog is open.
  101.      */
  102.     KCMultiDialog( int dialogFace, const KGuiItem &user2,
  103.             const KGuiItem &user3=KGuiItem(), int buttonMask=User2,
  104.             const QString &caption=i18n("Configure"), QWidget *parent=0,
  105.             const char *name=0, bool modal=false ) KDE_DEPRECATED;
  106.     // KDE4 remove the user3 argument, and instead initialize it to KStdGuiItem::adminMode.
  107.  
  108.     /**
  109.      * Destructor
  110.      **/
  111.    virtual ~KCMultiDialog();
  112.  
  113.     /**
  114.      * Add a module.
  115.      *
  116.      * @param module Specify the name of the module that is to be added
  117.      *               to the list of modules the dialog will show.
  118.      *
  119.      * @param withfallback Try harder to load the module. Might result
  120.      *                     in the module appearing outside the dialog.
  121.      **/
  122.     void addModule(const QString& module, bool withfallback=true);
  123.  
  124.     /**
  125.      * Add a module.
  126.      *
  127.      * @param moduleinfo Pass a KCModuleInfo object which will be
  128.      *                   used for creating the module. It will be added
  129.      *                   to the list of modules the dialog will show.
  130.      *
  131.      * @param parentmodulenames The names of the modules that should appear as
  132.      *                          parents in the TreeList. Look at the
  133.      *                          KDialogBase::addPage documentation for more info
  134.      *                          on this.
  135.      *
  136.      * @param withfallback Try harder to load the module. Might result
  137.      *                     in the module appearing outside the dialog.
  138.      **/
  139.     void addModule(const KCModuleInfo& moduleinfo, QStringList
  140.             parentmodulenames = QStringList(), bool withfallback=false);
  141.  
  142.     /**
  143.      * Remove all modules from the dialog.
  144.      */
  145.     void removeAllModules();
  146.  
  147.     /**
  148.      * @internal
  149.      * Re-implemented for internal reasons.
  150.      */
  151.     void show();
  152.  
  153. signals:
  154.     /**
  155.      * Emitted after all KCModules have been told to save their configuration.
  156.      *
  157.      * The applyClicked and okClicked signals are emitted before the
  158.      * configuration is saved.
  159.      */
  160.     void configCommitted();
  161.  
  162.     /**
  163.      * Emitted after the KCModules have been told to save their configuration.
  164.      * It is emitted once for every instance the KCMs that were changed belong
  165.      * to.
  166.      *
  167.      * You can make use of this if you have more than one component in your
  168.      * application. instanceName tells you the instance that has to reload its
  169.      * configuration.
  170.      *
  171.      * The applyClicked and okClicked signals are emitted before the
  172.      * configuration is saved.
  173.      *
  174.      * @param instanceName The name of the instance that needs to reload its
  175.      *                     configuration.
  176.      */
  177.     void configCommitted( const QCString & instanceName );
  178.  
  179. protected slots:
  180.     /**
  181.      * This slot is called when the user presses the "Default" Button.
  182.      * You can reimplement it if needed.
  183.      *
  184.      * @note Make sure you call the original implementation.
  185.      **/
  186.     virtual void slotDefault();
  187.  
  188.     /**
  189.      * This slot is called when the user presses the "Reset" Button.
  190.      * You can reimplement it if needed.
  191.      *
  192.      * @note Make sure you call the original implementation.
  193.      */
  194.     virtual void slotUser1();
  195.  
  196.     /**
  197.      * This slot is called when the user presses the "Apply" Button.
  198.      * You can reimplement it if needed.
  199.      *
  200.      * @note Make sure you call the original implementation.
  201.      **/
  202.     virtual void slotApply();
  203.  
  204.     /**
  205.      * This slot is called when the user presses the "OK" Button.
  206.      * You can reimplement it if needed.
  207.      *
  208.      * @note Make sure you call the original implementation.
  209.      **/
  210.     virtual void slotOk();
  211.  
  212.     /**
  213.      * This slot is called when the user presses the "Help" Button.
  214.      * It reads the DocPath field of the currently selected KControl
  215.      * module's .desktop file to find the path to the documentation,
  216.      * which it then attempts to load.
  217.      * 
  218.      * You can reimplement this slot if needed.
  219.      *
  220.      * @note Make sure you call the original implementation.
  221.      **/
  222.     virtual void slotHelp();
  223.  
  224. private slots:
  225.  
  226.     void slotAboutToShow(QWidget *);
  227.  
  228.     void clientChanged(bool state);
  229.  
  230.     /**
  231.      * Called when entering root mode, and disables
  232.      * the Admin Mode button such that the user doesn't do it
  233.      * twice.
  234.      *
  235.      * @since 3.4
  236.      */
  237.     void disableRModeButton();
  238.  
  239.     /**
  240.      * Called when the current module exits from root 
  241.      * mode. Enables the Administrator Mode button, again.
  242.      *
  243.      * @since 3.4
  244.      */
  245.     void rootExit();
  246.  
  247.     /**
  248.      *
  249.      * Called when the dialog is hidden. It unregisters the modules,
  250.      * such that they don't hinder the same modules to be opened in 
  251.      * another application.
  252.      *
  253.      * @since 3.4
  254.      */
  255.     void dialogClosed();
  256.  
  257. private:
  258.  
  259.     void init();
  260.     void apply();
  261.  
  262.     struct CreatedModule
  263.     {
  264.         KCModuleProxy * kcm;
  265.         KService::Ptr service;
  266.         /* KDE 4 Move to Private class */
  267.     };
  268.     typedef QValueList<CreatedModule> ModuleList;
  269.     ModuleList m_modules;
  270.  
  271.     typedef QMap<KService::Ptr, KCModuleProxy*> OrphanMap;
  272.     OrphanMap m_orphanModules;
  273.  
  274.     QPtrDict<QStringList> moduleParentComponents;
  275.     QString _docPath;
  276.     int dialogface;
  277.  
  278.     class KCMultiDialogPrivate;
  279.     KCMultiDialogPrivate *d;
  280. };
  281.  
  282. #endif //KCMULTIDIALOG_H
  283.  
  284. // vim: sw=4 sts=4 et
  285.